import React, { useEffect, useState } from "react";
import { Tabs } from 'antd';
import Index from './index'
import Detail from './detail';
import TabPane from "antd/es/tabs/TabPane";


let loadTabs = false
const Page = () => {
    const [items, setItems] = useState([])
    const [activeTab, setActiveTab] = useState("1")
    const [currentOrder, setCurrentOrder] = useState({})
    useEffect(() => {
    }, []);

    const onChange = (key) => {
        console.log(key);
        setActiveTab(key)
    };

    const toDetail = (row) => {
        if (activeTab != "2") {
            console.log(row)
            setCurrentOrder(row)
            setActiveTab(pretab => "2")
        }

    }

    return (
        <Tabs activeKey={activeTab} onChange={onChange} >
            <TabPane key="1" tab="列表">
                <Index onDbClickRow={r => toDetail(r)} />
            </TabPane>
            <TabPane key="2" tab="详情">
                <Detail order={currentOrder} />
            </TabPane>
        </Tabs>
    )
}

export default Page